import request from "@/utils/request";
import { ParamsType } from "@/api/employee/types";

/**
 * 工人花名册分页
 * @param data 请求参数
 */
export function getProjectGroupMemberList(data: ParamsType) {
  let url;
  switch (localStorage.getItem("usertypeName")) {
    case "Manager":
      url = "manager";
      break;
    case "Corp":
      url = "corp";
      break;
    case "Constructor":
      url = "constructor";
      break;
    case "Commander":
      url = "commander";
      break;
    case "SysUser":
      url = "sysuser";
      break;
  }
  return request({
    url: "/api/v1/" + url + "/useemployee/page_useEmployees",
    method: "get",
    params: data,
  });
}

/**
 * 查询人员
 * @param data 请求参数
 */
export function getPersonListByProjectAndCorp(data: ParamsType) {
  let url;
  switch (localStorage.getItem("usertypeName")) {
    case "Manager":
      url = "manager";
      break;
    case "Corp":
      url = "corp";
      break;
    case "Constructor":
      url = "constructor";
      break;
    case "Commander":
      url = "commander";
      break;
    case "SysUser":
      url = "sysuser";
      break;
  }
  return request({
    url: "/api/v1/" + url + "/useemployee/page_useEmployees_byCorpId",
    method: "get",
    params: data,
  });
}

export function downloadGroupMembers(data: ParamsType) {
  let url;
  switch (localStorage.getItem("usertypeName")) {
    case "Manager":
      url = "manager";
      break;
    case "Corp":
      url = "corp";
      break;
    case "Constructor":
      url = "constructor";
      break;
    case "Commander":
      url = "commander";
      break;
    case "SysUser":
      url = "sysuser";
      break;
  }
  return request({
    url: "/api/v1/" + url + "/useemployee/export",
    method: "get",
    responseType: "arraybuffer",
  });
}
